;(async function () {
  const express = require('express')
  const db = require('./db/connectdb')
  const adminRouter = require('./routes/adminRouter')

  try {
    await db
    console.log('数据库连接成功')
    const app = express()

    app.use(express.json())
    app.use(adminRouter)

    app.listen(5001, (err) => {
      if (err) console.log('fail')
      else console.log('ok')
    })
  } catch (error) {
    console.log('数据库连接失败')
  }
})()
